<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="com.mongodb.DBCursor"%>
<%@page import="controller.Utils"%>
<%@page import="com.mongodb.DBObject"%>
<% request.setCharacterEncoding("utf-8");%>
<%

DBObject domain = (DBObject) request.getAttribute("domain");
DBCursor subdomain = (DBCursor) request.getAttribute("subdomain");
DBCursor sameDomain = (DBCursor) request.getAttribute("sameDomain");
DBCursor googleAnalytic = (DBCursor) request.getAttribute("googleAnalytic");
DBCursor googleAdsense = (DBCursor) request.getAttribute("googleAdsense");
DBCursor inlink = (DBCursor) request.getAttribute("inlink");
DBCursor ip = (DBCursor) request.getAttribute("ip");
DBCursor random = (DBCursor) request.getAttribute("random");
String search = (String) request.getAttribute("search");
String re_title = domain.get("name").toString();

String title = domain.get("name").toString();
String description = domain.get("name").toString()+".A Free SEO tool that provides free website analysis, traffic details, rankings, contact email ,similar site, same owner site , same ip site, optimization and promotion reports.";
String keyword = "Domain name information,  Server information, Web site analysis, website traffic details, Website backlinks website IP, website ranking info";

title = (domain.get("title")!=null)?Utils.returnDomain(domain.get("name").toString())+" "+domain.get("name").toString()+" "+domain.get("title").toString():Utils.returnDomain(domain.get("name").toString())+" "+domain.get("name").toString();

if(domain.get("lKeyword")!=null)
{
	ArrayList<String> lKeyword = (ArrayList<String>)domain.get("lKeyword");	
	for(int i=0;i<lKeyword.size();i++)
	{
		keyword += lKeyword.get(i).toString()+",";
	}
}
if(domain.get("lpKeyword")!=null)
{
	ArrayList<String> lpKeyword = (ArrayList<String>)domain.get("lpKeyword");	
	for(int i=0;i<lpKeyword.size();i++)
	{
		keyword += lpKeyword.get(i).toString()+",";
	}
}
if(keyword.equals(""))
{
	keyword = "Domain name information,  Server information, Web site analysis, website traffic details, Website backlinks website IP, website ranking info";
}

description = (domain.get("description")!=null)?domain.get("description").toString():keyword+",Domain name information,  Server information, Web site analysis, website traffic details, Website backlinks website IP, website ranking info";
if(description.length() > 250)
{
	description = description.substring(0,250);
}

if(keyword.length() > 250)
{
	keyword = keyword.substring(0,250);
}

NumberFormat nf = NumberFormat.getInstance();

long date = new Date().getTime();
long dates = new Date().getTime();
if(domain.get("update") != null)
{
	dates = Long.parseLong(domain.get("update").toString());
}
long seconds = (date - dates)/1000;
long day = (int) (seconds / 86400);
long hour = (int) ((seconds - day*86400) / 3600);
long minute = (int) ((seconds - day*86400 - hour*3600) / 60);
if(hour<0)
{
	hour = 0;	
}
if(minute<0)
{
	minute = 0;	
}
if(day<0)
{
	day = 0;	
}
String names = domain.get("name").toString();
%>
<%@page contentType="text/html;charset=UTF-8" language="java"%>
<jsp:include page="layout/header.jsp">
	<jsp:param name="title" value="<%=title %>"/>
	<jsp:param name="description" value="<%=description %>"/>
	<jsp:param name="keywords" value="<%=keyword %>"/>
	<jsp:param name="img" value="<%=names %>"/>
</jsp:include>
		<div class="body all">
			<div class="cate">
				<%@ include file='/element/menu_left.jsp'%>
				<%@ include file='/adv/left_detail.jsp'%>
				<div class="update">
					
				</div>
				<hr size="1" class="hr"/>
				<h2 class="menu">Random sites</h2>
				<ul class="featured">
					<%
					ArrayList<String> siteRandom = (ArrayList<String>)domain.get("siteRandom");
					for(int i=0;i<siteRandom.size();i++)
					{
					%>
						<li><a href="/domain/<%=siteRandom.get(i)%>" title="<%=siteRandom.get(i) %>"><%=siteRandom.get(i) %></a></li>
					<%
					}	
					%>
				</ul>
			</div>
			<div class="content">
				<%@ include file='/adv/menu.jsp'%>
				<h2 class="title left size_20">
					<%=domain.get("name") %>
					<%
					if(day>=2 || domain.get("update") == null)
					{
					%>
								( <a href="javascript:void(0)" rel="nofollow" id="update">Update</a> )
					<%
					}
					%>
				</h2>
				
				<div class="add_this right zero_r">
					<!-- AddThis Button BEGIN -->
					<div class="addthis_toolbox addthis_default_style ">
					<a class="addthis_button_preferred_1"></a>
					<a class="addthis_button_preferred_2"></a>
					<a class="addthis_button_preferred_3"></a>
					<a class="addthis_button_preferred_4"></a>
					<a class="addthis_button_compact"></a>
					<a class="addthis_counter addthis_bubble_style"></a>
					</div>
					<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
					<!-- AddThis Button END -->
				</div>
				<div class="sum_one right">
					<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
					<g:plusone size="small" count="true"></g:plusone>
				</div>
				<div class="clear"></div>
				Updated<b>
				<%
					if(day > 0)
					{
						out.print(day+" days, ");
					}
					if(hour > 0)
					{
						out.print(hour+" hours, ");
					}
					out.print(minute+" minutes");
				%>	</b> Ago<br/><br/>
				<%@ include file='/adv/note.jsp'%>
				<br/><br/>
				<p>
					<strong><%=domain.get("name") %></strong> <%=Utils.returnSubDomain(domain.get("name").toString()) %> ,has parerank is <strong><%=domain.get("googlePagerank") %></strong> ,the domain is <strong><%=Utils.checkLengthDomain(domain.get("name").toString()) %></strong> characters in length,
					the number of visitors to the site an average of <%=(domain.get("visit")!=null && !domain.get("visit").equals("-"))?nf.format(Math.ceil(((350*Float.parseFloat(domain.get("visit").toString().replaceAll("[^0-9.]","")))*80)/0.03))+" - "+nf.format(Math.ceil(((350*Float.parseFloat(domain.get("visit").toString().replaceAll("[^0-9.]","")))*120)/0.03)):"-" %>
					,the average speed of the site is   <%=(domain.get("speed")!=null)?Float.valueOf(domain.get("speed").toString())+" Seconds":"-" %> .
				</p>
				<br/>
				<div class="ti">Ranking info</div>
				<ul class="detail">
					<li>
						<div class="detail_left left">Google pagerank:</div>
						<div class="detail_right left"><a href="http://prapi.net?url=<%=domain.get("name")%>" target="_blank" rel="nofollow"><%=domain.get("googlePagerank")!=null?domain.get("googlePagerank"):"-" %></a></div>
					</li>
					<li>
						<div class="detail_left left">Alexa rank:</div>
						<div class="detail_right left"><%=(domain.get("rank") != null)?nf.format(domain.get("rank")):"-" %></div>
					</li>
				</ul>

				<div class="ti">Site info </div>
				<ul class="detail">
					<li>
						<div class="detail_left left">Domain</div>
						<div class="detail_right left">
							<%
							if(domain.get("name")!=null)
							{
							%>
								<strong>
									<%=domain.get("name") %>
								</strong>
								<br/><strong>Length : <%=Utils.checkLengthDomain(domain.get("name").toString()) %></strong>
								characters
							<%
							} else {
								out.println(domain.get("name"));
							}
							%>
							
						</div>
					</li>
					<li>
						<div class="detail_left left">5ty.org</div>
						<div class="detail_right left">
							View <a href="http://5ty.org/d/<%=domain.get("name") %>" target="_blank" rel="nofollow"><%=domain.get("name") %></a> in 5ty.org
						</div>
					</li>
					<%
					if(subdomain != null && subdomain.size() > 0)
					{
					%>
					<li>
						<div class="detail_left left">Other Domain</div>
						<div class="detail_right left">
							<%
								while(subdomain.hasNext())
								{
									String name = subdomain.next().get("name").toString();
									out.println("<a href='/domain/"+name+"'>"+name+"</a> | ");
								}
							%>
						</div>
					</li>
					<%
					}
					%>
					<li>
						<div class="detail_left left">Title</div>
						<div class="detail_right left">
							<%
							if(domain.get("title")!=null)
							{
							%>
								<%=domain.get("title") %>
								<br/><strong>Length : <%=domain.get("title").toString().length() %></strong>
								characters
							<%
							} else {
								out.println(domain.get("name"));
							}
							%>
						</div>
					</li>
					<li>
						<div class="detail_left left">Keywords</div>
						<div class="detail_right left">
							<%
							keyword = "";
							int count = 0;
							if(domain.get("lKeyword")!=null)
							{
								ArrayList<String> arrayList = (ArrayList<String>)domain.get("lKeyword");
								
								for(int i=0;i<arrayList.size();i++)
								{
									count++;
									keyword += arrayList.get(i);
							%>
									<a href="/keyword/<%=arrayList.get(i) %>"><%=arrayList.get(i) %></a> | 
							<%
								}
							}
							%>
							<br/><strong>Length : <%=keyword.length() %></strong>
							characters
							<br/><strong>Numbers : <%=count %></strong>
							keywords
						</div>
					</li>
					<li>
						<div class="detail_left left">Popular Keywords</div>
						<div class="detail_right left">
							<%
									if(domain.get("lpKeyword")!=null)
									{
										ArrayList<String> arrayList = (ArrayList<String>)domain.get("lpKeyword");
										for(int i=0;i<arrayList.size();i++)
										{
									%>
											<a href="/keyword/<%=arrayList.get(i) %>"><%=arrayList.get(i) %></a> | 
									<%
										}
									}
									%>
						</div>
					</li>
					<li>
						<div class="detail_left left">Description</div>
						<div class="detail_right left">
							<%=(domain.get("description")!=null)?domain.get("description"):"No Description" %><br/>
							<strong>Length : <%=(domain.get("description")!=null)?domain.get("description").toString().length():"0" %></strong>  characters
						</div>
					</li>
					<li>
						<div class="detail_left left">Estimate Visitor per Day:</div>
						<div class="detail_right left"><%=(domain.get("visit")!=null && !domain.get("visit").equals("-"))?nf.format(Math.ceil(((350*Float.parseFloat(domain.get("visit").toString().replaceAll("[^0-9.]","")))*80)/0.03))+" - "+nf.format(Math.ceil(((350*Float.parseFloat(domain.get("visit").toString().replaceAll("[^0-9.]","")))*120)/0.03)):"-" %></div>
					</li>
					<li>
						<div class="detail_left left">Speed site:</div>
						<div class="detail_right left"><%=(domain.get("speed")!=null)?Float.valueOf(domain.get("speed").toString().replaceAll("[^0-9.]",""))+" Seconds":"-" %></div>
					</li>
					<li>
						<div class="detail_left left">Domain Age:</div>
						<div class="detail_right left"><%=(domain.get("age")!=null)?domain.get("age"):"-" %></div>
					</li>
					<li>
						<div class="detail_left left">Charset:</div>
						<div class="detail_right left"><%=(domain.get("charset")!=null)?domain.get("charset"):"-" %></div>
					</li>
					<li>
						<div class="detail_left left">WOT:</div>
						<div class="detail_right left"><%=(domain.get("wot")!=null)?domain.get("wot"):"-" %></div>
					</li>
				</ul>
				<div class="ti">Site Contact Info</div>
				<ul class="detail">
					<li>
						<div class="detail_left left">Site's same Google Analytic (<%=(domain.get("googleAnalytics")!=null)?domain.get("googleAnalytics"):"-" %>):</div>
						<div class="detail_right left">
							<%
							if(googleAnalytic != null && googleAnalytic.size()>0)
							{
								while(googleAnalytic.hasNext())
								{
									String name = googleAnalytic.next().get("name").toString();
									out.print("<a href='/domain/"+name+"'>"+name+"</a> | ");
								}
							}
							%>
						</div>
					</li>
					<li>
						<div class="detail_left left">Site's same Google Adsense (<%=(domain.get("googleAdsense")!=null)?domain.get("googleAdsense"):"-" %>):</div>
						<div class="detail_right left">
							<%
							if(googleAdsense != null && googleAdsense.size()>0)
							{
								while(googleAdsense.hasNext())
								{
									String name = googleAdsense.next().get("name").toString();
									out.print("<a href='/domain/"+name+"'>"+name+"</a> | ");
								}
							}
							%>						
						</div>
					</li>
				</ul>
				<div class="ti">Site Technical Info</div>
				<ul class="detail">
					<li>
						<div class="detail_left left">Programming Language:</div>
						<div class="detail_right left"><%=(domain.get("language")!=null)?domain.get("language"):"-" %></div>
					</li>
					<li>
						<div class="detail_left left">Web server:</div>
						<div class="detail_right left"><%=(domain.get("server")!=null)?domain.get("server"):"-" %></div>
					</li>
					<li>
						<div class="detail_left left">Javascript library:</div>
						<div class="detail_right left"><%=(domain.get("js")!=null)?Utils.returnString(domain.get("js").toString(),""):"-" %></div>
					</li>
					<li>
						<div class="detail_left left">IP Address:</div>
						<div class="detail_right left">
							<%=(domain.get("ip")!=null)?"<a href='/ip/"+domain.get("ip")+"'>"+domain.get("ip")+"</a>":"-" %>
						</div>
					</li>
					<li>
						<div class="detail_left left">Whois: <% out.println("<a href='/whois/"+domain.get("name")+"'>( More detail... )</a>"); %></div>
						<div class="detail_right left whoiss">
							<%=(domain.get("whois")!=null)?Utils.returnWhois(domain.get("whois").toString()):"" %>
						</div>
					</li>
				</ul>
				<div class="ti">Site Seo</div>
				<ul class="detail">
					<li>
						<div class="detail_left left">Tag :</div>
						<div class="detail_right left">
							<table>
								<tr>
									<td>H1</td>
									<td>H2</td>
									<td>H3</td>
									<td>H4</td>
									<td>H5</td>
								</tr>
								<tr>
									<th><%=(domain.get("h1")!=null)?domain.get("h1"):"0" %></th>
									<th><%=(domain.get("h2")!=null)?domain.get("h2"):"0" %></th>
									<th><%=(domain.get("h3")!=null)?domain.get("h3"):"0" %></th>
									<th><%=(domain.get("h4")!=null)?domain.get("h4"):"0" %></th>
									<th><%=(domain.get("h5")!=null)?domain.get("h5"):"0" %></th>
								</tr>
							</table>
						</div>
					</li>
					<li>
						<div class="detail_left left">Image:</div>
						<div class="detail_right left">
							You have <strong><%=(domain.get("img")!=null)?domain.get("img"):"-" %></strong> images on this website.
						</div>
					</li>
					<li>
						<div class="detail_left left">Frame:</div>
						<div class="detail_right left"><%=(domain.get("frame")!=null && !domain.get("frame").equals(0))?domain.get("frame"):"No" %></div>
					</li>
					<li>
						<div class="detail_left left">Flash:</div>
						<div class="detail_right left">
							You have <strong><%=(domain.get("flash")!=null && !domain.get("flash").equals(0))?domain.get("flash"):"No" %></strong> flash on this website.
						</div>
					</li>
					<li>
						<div class="detail_left left">Size:</div>
						<div class="detail_right left"><%=(domain.get("size")!=null)?nf.format(domain.get("size"))+" characters":"-" %></div>
					</li>
					<li>
						<div class="detail_left left">Meta Description:</div>
						<div class="detail_right left"><%=(domain.get("metaDesc")!=null && domain.get("metaDesc").equals(1))?"Yes":"No" %></div>
					</li>
					<li>
						<div class="detail_left left">Meta Keyword:</div>
						<div class="detail_right left"><%=(domain.get("metaKey")!=null && domain.get("metaKey").equals(1))?"Yes":"No" %></div>
					</li>
				</ul>
				<div class="ti">Cross link</div>
				<ul class="detail">
					<%
					if(domain.get("link")!=null && !Utils.returnString(domain.get("link").toString(),"domain").trim().equals(""))
					{
					%>
					<li>
						<div class="detail_left left">Out link: <a href="/link-out/<%=domain.get("name")%>">View all</a></div>
						<div class="detail_right left">
							<%
								if(domain.get("link")!=null)
								{
									out.print(Utils.returnString(domain.get("link").toString(),"domain"));
								}
							%>
						</div>
					</li>
					<%
					}
					if(inlink != null && inlink.size()>0)
					{
					%>
					<li>
						<div class="detail_left left">In link: <a href="/link-in/<%=domain.get("name")%>">View all</a></div>
						<div class="detail_right left">
							<%
							
								while(inlink.hasNext())
								{
									String name = inlink.next().get("name").toString();
									out.print("<a href='/domain/"+name+"' >"+name+"</a> | ");
								}
							%>
						</div>
					</li>
					<%
					}
					%>
				</ul>
				<div class="ti">Domain Traffic Graph</div>
				<div>
					<div class="daily left">Daily Rank</div>
					<div class="daily right">Daily PageViews</div>
					<img src="http://traffic.alexa.com/graph?c=1&amp;u=<%=domain.get("name") %>&amp;r=6m&amp;y=t&amp;z=3&amp;h=200&amp;w=280&amp;b=FFFFFF" class="left"/>
					<img src="http://traffic.alexa.com/graph?c=1&amp;u=<%=domain.get("name") %>&amp;r=6m&amp;y=r&amp;z=3&amp;h=200&amp;w=280&amp;b=FFFFFF" class="right"/>
					<div class="clear"></div>
				</div>
				<div class="ti">Other sites hosted on <%=(domain.get("ip")!=null)?"<a href='/ip/"+domain.get("ip")+"'>"+domain.get("ip")+"</a>":"-" %></div>
				<ul class="detail">
					<% if (sameDomain!=null) %>
					<%=Utils.returnSame(sameDomain) %>
				</ul>
			</div>
			<div class="clear"></div>
		</div>
		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
		<script type="text/javascript"src="/js/detail.js"></script>
		<script type="text/javascript" src="/js/update.js"></script>	
		<script type="text/javascript">
			var domain = '<%=domain.get("name")%>';
		</script>
		<div id='opacity'></div>
<img src="/images/ajax-loader.gif" id='image_loadder'/>
<%@ include file='/layout/footer.jsp'%>